import * as CST from './constants';
import {
  mapActions
} from 'vuex';

export default {
  name: 'login',
  data() {
    return {
      ...CST,
      params: {
        name: "13800000002",
        password: '123456'
        // name: '',
        // password: '',
      },
      loginRules: {
        name: [{
            required: true,
            message: '请输入用户名',
            trigger: 'blur',
          },
          {
            // 策略模式
            required: true,
            min: 6,
            max: 11,
            message: '用户名应为6到11位',
            trigger: 'blur',
          },
        ],
        password: [{
            required: true,
            message: '请输入密码',
            trigger: 'blur',
          },
          {
            required: true,
            min: 6,
            max: 16,
            message: '长度应为6到16位',
            trigger: 'blur',
          },
        ],
      },
    };
  },
  methods: {
    ...mapActions('user', ['login']),
    onLogin() {
      this.login(this.params);
    },
  },
};
